import requests
import logging
import config


class LoginAPI:

    # 登录接口
    @classmethod
    def login(cls, body):
        url = config.monitor_domain + "/login"
        headers = {"content-type": "application/json"}
        logging.info(f"login_url:{url}")
        resp = requests.post(url=url, headers=headers, json=body)
        logging.info(f"login_resp:{resp.text}")
        return resp

    # 获取用户信息接口
    @classmethod
    def getUserInfo(cls, token):
        url = config.monitor_domain + "/getUserInfo"
        headers = {"Authorization": token}
        logging.info(f"getUserInfo_url:{url}")
        resp = requests.get(url=url, headers=headers)
        logging.info(f"getUserInfo_resp:{resp.text}")
        return resp

    # 获取路由信息
    @classmethod
    def getRouters(cls, token):
        url = config.monitor_domain + "/getRouters"
        headers = {"Authorization": token}
        logging.info(f"getRouters_url:{url}")
        resp = requests.get(url=url, headers=headers)
        logging.info(f"getRouters_resp:{resp.text}")
        return resp
    #查询登录策略详情
    @classmethod
    def sysLoginStrategy(cls,token):
        url = config.monitor_domain + "/sysLoginStrategy/detail"
        headers = {"Authorization": token}
        logging.info(f"sysLoginStrategy URL:{url}")
        resp = requests.get(url=url, headers=headers)
        logging.info(f"sysLoginStrategy Resp:{resp.text}")
        return resp

